package com.chs.recoginition.vo;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * 分页响应
 */
@Data
public class PageRespVo<T> extends Page<T> implements Serializable {
    private static final long serialVersionUID = -6163094316971891118L;
    //总页数
    private long totalPage;

    public long getTotalPage() {
        if(super.getTotal()%super.getSize()==0) {
            return getTotal()/super.getSize();
        }else {
            return (getTotal()/super.getSize())+1;
        }
    }

    /**
     * 不分页的总行数
     */
    @Override
    public long getTotal() {
        return super.getTotal();
    }

    /**
     * 当前页的内容
     */
    public List<T> getRows() {
        return super.getRecords();
    }

    @Override
    @JsonIgnore
    public List<T> getRecords() {
        return super.getRecords();
    }

    @Override
    @JsonIgnore
    public long getSize() {
        return super.getSize();
    }

    @Override
    @JsonIgnore
    public long getCurrent() {
        return super.getCurrent();
    }

    @Override
    @JsonIgnore
    public long getPages() {
        return super.getPages();
    }

    @Override
    @JsonIgnore
    public boolean isSearchCount() {
        return super.isSearchCount();
    }

    @Override
    public int hashCode() {
        int result = 1;
        Object records = this.getRecords();
        result = result * 59 + (records == null ? 43 : records.hashCode());
        Object total = this.getTotal();
        result = result * 59 + total.hashCode();
        Object size = this.getSize();
        result = result * 59 + size.hashCode();
        Object current = this.getCurrent();
        result = result * 59 + current.hashCode();
        Object ascs = this.ascs();
        result = result * 59 + (ascs == null ? 43 : ascs.hashCode());
        Object descs = this.descs();
        result = result * 59 + (descs == null ? 43 : descs.hashCode());
        Object optimizeCountSql = this.optimizeCountSql();
        result = result * 59 + optimizeCountSql.hashCode();
        Object isSearchCount = this.isSearchCount();
        result = result * 59 + isSearchCount.hashCode();
        return result;
    }
}
